package cn.mdmbct.spring.starter.douyin.common.properties.dy;

import cn.mdmbct.spring.starter.douyin.common.properties.storage.StorageProperties;
import lombok.Getter;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.io.Serializable;

/**
 * 抖音open api yml配置
 *
 * @author mdmbct  mdmbct@outlook.com
 * @date 2021/4/25 10:41
 * @modified mdmbct
 * @since 1.0
 */

@Getter
@ConfigurationProperties(prefix = DyOpenApiProperties.PREFIX)
public class DyOpenApiProperties implements Serializable {

    public static final String PREFIX = "dy.open";

    private static final long serialVersionUID = -4388439636038245858L;

    /**
     * redis存储open api的key 默认"dy.api"
     */
    private String configCacheKey = PREFIX;

    /**
     * 多线程上传时的线程数  默认1 1 ~ 8 超过8会被设置成8 小于1会被设置成1
     */
    private int uploadThreadNum = 1;

    private AppProperties app;

    private HttpProperties http = new HttpProperties();

    private StorageProperties storage = new StorageProperties();

    public String getConfigCacheKey() {
        return configCacheKey;
    }

    public void setConfigCacheKey(String configCacheKey) {
        this.configCacheKey = configCacheKey;
    }

    public void setApp(AppProperties app) {
        this.app = app;
    }

    public void setHttp(HttpProperties http) {
        this.http = http;
    }

    public void setStorage(StorageProperties storage) {
        this.storage = storage;
    }

    public void setUploadThreadNum(int uploadThreadNum) {
        if (uploadThreadNum < 1) {
            this.uploadThreadNum = 1;
        } else {
            this.uploadThreadNum = Math.min(uploadThreadNum, 8);
        }
    }
}